package com.kgc.storeprovider.service.impl;


import com.kgc.basic.util.ResponseMsg;
import com.kgc.store.pojo.InStoreDetail;
import com.kgc.storeprovider.dao.InStoreDetailMapper;
import com.kgc.storeprovider.service.InStoreDetailService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class InStoreDetailServiceImpl implements InStoreDetailService {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private InStoreDetailMapper inStoreDetailMapper;

    @Override
    public ResponseMsg getInStoreDetailList(String inStoreCode) {
        logger.info("InStoreDetailServiceImpl getInStoreDetailList inStoreCode:"+inStoreCode);
        ResponseMsg msg = new ResponseMsg();
        List<InStoreDetail> inStoreDetailList = inStoreDetailMapper.getInStoreDetailList(inStoreCode);
        logger.debug("InStoreDetailServiceImpl getInStoreDetailList inStoreCode:"+inStoreCode);
        msg.setCode("200");
        msg.setData(inStoreDetailList);
        logger.debug("InStoreServiceImpl getInStoreList msg:"+msg);
        return msg;
    }

    @Override
    public ResponseMsg delInStoreDetail(Integer id) {
        ResponseMsg msg = new ResponseMsg();
        int delCount = inStoreDetailMapper.delInStoreDetail(id);
        if(delCount>0){
            msg.setData(true);
            msg.setCode("200");
        }else{
            msg.setData(false);
            msg.setCode("201");
        }
        return msg;
    }

    @Override
    public ResponseMsg addInStoreDetail(InStoreDetail inStoreDetail) {
        ResponseMsg msg = new ResponseMsg();
        int insertCount = inStoreDetailMapper.insertInStoreDetail(inStoreDetail);
        if(insertCount>0){
            msg.setData(true);
            msg.setCode("200");
        }else{
            msg.setData(false);
            msg.setCode("201");
        }
        return msg;
    }
}
